package test;

import com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList;

import data.objects.PubForum;
import data.objects.PubThread;
import data.objects.PubEntry;

public class ClearTable {
	public static AmazonDynamoDBClient dynamoDB;
	public static  DynamoDBMapper mapper;
	public static void main(String[] args) {		
		dynamoDB = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider());
        Region euWest1 = Region.getRegion(Regions.EU_WEST_1);
        dynamoDB.setRegion(euWest1);        
        mapper = new DynamoDBMapper(dynamoDB);
        
        DynamoDBScanExpression scanExpression1 = new DynamoDBScanExpression();
		PaginatedScanList<PubForum> all = mapper.scan(PubForum.class, scanExpression1);
		for(PubForum a:all){
			mapper.delete(a);
		}
		DynamoDBScanExpression scanExpression2 = new DynamoDBScanExpression();
		PaginatedScanList<PubThread> all2 = mapper.scan(PubThread.class, scanExpression2);
		for(PubThread b:all2){
			mapper.delete(b);
		}
		DynamoDBScanExpression scanExpression3 = new DynamoDBScanExpression();
		PaginatedScanList<PubEntry> all3 = mapper.scan(PubEntry.class, scanExpression3);
		for(PubEntry c:all3){
			mapper.delete(c);
		}
		
	}
	
	
	
	
}
